package book.spec;

import java.security.NoSuchAlgorithmException;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;

/**
 * 用于密钥规范，用于还原对称加密的密钥
 */
public class SecretKeyTest {

	public static void main(String[] args) throws NoSuchAlgorithmException {
		
		KeyGenerator gen = KeyGenerator.getInstance("RC2");
		SecretKey key = gen.generateKey();
		byte[] keyBytes = key.getEncoded();
		
		SecretKey key2 = new SecretKeySpec(keyBytes, "rc2"); 
		System.out.println(key2.equals(key2));
	}
}
